// Copyright 2024 Administrator
// 
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import { Transform } from "class-transformer";
import { IsArray, IsNumber, IsOptional, IsString } from "class-validator";
import { PageDto } from "src/common/dto/page.dto";
import { LangEnum } from "src/common/enums";
import { ResolutionEnum } from "src/common/enums/video.enum";
import { Video } from "../entities/video.entity";
import { ResolutionType } from "./create-video.dto";

export class VideoDto extends Video {
    //当前登录用户是否喜欢
    isFavorite: number;
    //推荐的排序
    recommendSort: number;
    //播放地址
    path: string;
    //清晰度(r1080 r720 r480 r360)
    resolution: string[];
    //对应的歌曲code
    trackAssetCode: string[];

    //类型eg:2

    type: number;
    upc: string;

    baseId: number;
}


export class VideoVo {

    //视频id
    id?: string;

    url?: string;
    /**
     * 歌手ID列表
     */
    artistIds: number[];

    //视频、图片高度
    height?: number;
    //视频、图片宽度
    width?: number;
    //视频时长
    duration?: number;

    //存储名称
    objectName?: string;

    //唯一Code
    assetCode?: string;

    //简介
    introduce: string;

    //语言缩写(zh)
    lang: LangEnum;

    //标签 id或者文本
    genre?: number | string;

    //封面图
    poster: string;

    //发行时间
    originalReleaseDate: string;

    //mv标题
    title: string;

    //新增时间?
    indexDataAddTime: string;

    //播放总次数
    playnum: number;

    allRate?: ResolutionType[]
    //分辨率
    resolution?: ResolutionEnum[]
    //歌曲的id

    trackId?: string[]

    trackAssetCode?: string[]
    songOptions: { label: string; value: number; }[];


    songIds: number[];
}

export class VideoPageQuery extends PageDto {
    @IsOptional()
    @IsString()
    name: string

    @IsOptional()
    @IsArray()
    @Transform(arr => arr.map(a => +a))
    @IsNumber({ allowNaN: false }, { message: "歌手id必须是数字", each: true })
    artistIds?: number[]
}